import numpy as np


def mathCal():
    """
    基本数学运算
    :return:
    """
    # 加法
    arr1 = np.array([1, 2])
    arr2 = np.array([3, 4])

    # 加法
    add1 = arr1 + arr2
    add2 = np.add(arr1, arr2)

    # 减法
    sub1 = arr1 - arr2
    sub2 = np.subtract(arr1, arr2)

    # 乘法
    mult1 = arr1 * arr2
    mult2 = np.multiply(arr1, arr2)

    # 除法
    div1 = arr1 / arr2
    div2 = np.divide(arr1, arr2)
    div3 = np.divide(arr1, 10)

    # 幂运算
    power1 = arr1 ** arr2
    power2 = np.power(arr1, arr2)

    print(add1)
    print(add2)
    print(sub1)
    print(sub2)
    print(mult1)
    print(mult2)
    print(div1)
    print(div2)
    print(div3)
    print(power1)
    print(power2)

def aroundFun():
    """
    四舍五入相关方法
    :return:
    """
    data = [1.1234, 1.5678, 0, -1.1234, -1.5678]

    source = np.array(data)

    # 四舍五入，取整
    around = np.around(source)

    # 四舍五入，保留小数点2位
    around2 = np.around(source, 2)

    # 四舍五入，并向上取整
    ceil = np.ceil(source)

    # 四舍五入，并向下取整
    floor = np.floor(source)

    print(around)
    print(around2)
    print(ceil)
    print(floor)


if __name__ == '__main__':
    # mathCal()
    aroundFun()
